<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		#div1{
			width: 200px;
			height: 200px;
			background: red;
			position: absolute;
			bottom: 0;
			right: 0;
		}
		body{
			height:3000px;
		}
	</style>
	<script type="text/javascript">
		window.onscroll=window.onresize=function(){
			var oDiv=document.getElementById('div1');
			var scrollTop = document.documentElement.scrollTop||document.body.scrollTop;

			var clientHeight=document.documentElement.clientHeight;
			oDiv.style.top=clientHeight-oDiv.offsetHeight+scrollTop+'px';
            console.log(clientHeight-oDiv.offsetHeight+scrollTop);
		}
	</script>
</head>
<body>
	<div id="div1"></div>
</body>
</html>